package com.sunyard.utils.msg;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;

import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;

public class MD5Util {

    private static Logger logger = LoggerFactory.getLogger(MD5Util.class);


    public static String getMd5Str(Map<String, String> paramTreeMap) {
        TreeMap<String, String> temp = new TreeMap<String, String>(paramTreeMap);
        StringBuffer sb = new StringBuffer();
        // 获得加密字符串
        Iterator<String> it = temp.keySet().iterator();
        String sop = "";
        String k = "";
        while (it.hasNext()) {
            k = it.next();
            if (!StringUtils.isEmpty(temp.get(k))) {
                sop += k + "=" + temp.get(k) + "&";
            } else {
                paramTreeMap.remove(k);
            }
        }
        sop = sop.substring(0, sop.length() - 1);
        return sop;
    }
}
